package org.doubango.ngn.utils.refactor;

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.Date;

import org.doubango.ngn.model.refactoring.Nullable;
import org.doubango.ngn.utils.NgnDateTimeUtils;

public class NullDateFormat extends DateFormat implements Nullable{
	/**
	 * serialVersionUID = -165798107114606954L
	 */
	private static final long serialVersionUID = -165798107114606954L;

	public NullDateFormat(){
		
	}
	
	@Override
	public boolean isNull() {
		return true;
	}

	@Override
	public StringBuffer format(Date date, StringBuffer buffer,
			FieldPosition field) {
		return null;
	}

	@Override
	public Date parse(String string, ParsePosition position) {
		
		return null;
	}
	
	@Override
	public Date parse(String string) {
		Date date;
		try {
			date = NgnDateTimeUtils.sDefaultDateFormat.parse(string);
		} catch (ParseException e) {
			date = new Date();
			e.printStackTrace();
		}
		
		return date;
	}

}
